#include <fbuffer.h>
Public Types | |
enum | swapSize { kSwap16 = 2, kSwap32 = 4, kSwap64 = 8 } |
Public Member Functions | |
Buffer () | |
Default constructor, allocates no memory at all. | |
Buffer (void *b, uint32 size) | |
Constructor - creates a new Buffer with a given size and copies contents from optional memory pointer. | |
Buffer (uint32 size, uint8 initVal) | |
Constructor - creates a new Buffer with a given size and fills it all with a given value. | |
Buffer (uint32 size) | |
Constructor - creates a new Buffer with a given size. | |
Buffer (const Buffer &buff) | |
Copy constructor - creates a new Buffer from a given Buffer. | |
~Buffer () | |
Destructor - deallocates the internal memory. | |
void | operator= (const Buffer &buff) |
Assignment operator - copies contents from a given Buffer and increases the size if necessary. | |
bool | operator== (const Buffer &buff) const |
Comparison operator - copies contents from a given Buffer and increases the size if necessary. | |
uint32 | getSize () const |
bool | setSize (uint32 newSize) |
Sets a new size for this Buffer, keeping as much content as possible. | |
bool | grow (uint32 memSize) |
Increases the Buffer to the next block, block size given by delta. | |
bool | setMaxSize (uint32 memSize) |
see grow() | |
void | fillup (uint8 initVal=0) |
set from fillSize to end | |
uint32 | getFillSize () const |
bool | setFillSize (uint32 c) |
sets a new fill size, does not change any memory | |
void | flush () |
sets fill size to zero | |
bool | truncateToFillSize () |
bool | isFull () const |
uint32 | getFree () const |
void | shiftStart (int32 amount) |
moves all memory by given amount, grows the Buffer if necessary | |
void | shiftAt (uint32 position, int32 amount) |
moves memory starting at the given position | |
void | move (int32 amount, uint8 initVal=0) |
shifts memory at start without growing the buffer, so data is lost and initialized with init val | |
bool | copy (uint32 from, uint32 to, uint32 bytes) |
copies a number of bytes from one position to another, the size may be adapted | |
uint32 | get (void *b, uint32 size) |
copy to buffer from fillSize, and shift fillSize | |
void | setDelta (uint32 d) |
define the block size by which the Buffer grows, see grow() | |
bool | put (uint8) |
append value at end, grows Buffer if necessary | |
bool | put (char16 c) |
append value at end, grows Buffer if necessary | |
bool | put (char c) |
append value at end, grows Buffer if necessary | |
bool | put (const void *, uint32 size) |
append bytes from a given buffer, grows Buffer if necessary | |
bool | put (void *, uint32 size) |
append bytes from a given buffer, grows Buffer if necessary | |
bool | put (uint8 *, uint32 size) |
append bytes from a given buffer, grows Buffer if necessary | |
bool | put (char8 *, uint32 size) |
append bytes from a given buffer, grows Buffer if necessary | |
bool | put (const uint8 *, uint32 size) |
append bytes from a given buffer, grows Buffer if necessary | |
bool | put (const char8 *, uint32 size) |
append bytes from a given buffer, grows Buffer if necessary | |
bool | put (const String &) |
append String at end, grows Buffer if necessary | |
void | set (uint8 value) |
fills complete Buffer with given value | |
bool | appendString (const char *s) |
bool | appendString (char *s) |
bool | appendString (char c) |
bool | appendString8 (const char8 *s) |
bool | appendString16 (const char16 *s) |
bool | appendString8 (char8 *s) |
bool | appendString8 (unsigned char *s) |
bool | appendString8 (const unsigned char *s) |
bool | appendString8 (char8 c) |
bool | appendString8 (unsigned char c) |
bool | appendString16 (char16 c) |
bool | appendString16 (char16 *s) |
bool | prependString (const char *s) |
bool | prependString (char *s) |
bool | prependString (char c) |
bool | prependString8 (const char8 *s) |
bool | prependString16 (const char16 *s) |
bool | prependString8 (char8 c) |
bool | prependString8 (unsigned char c) |
bool | prependString8 (char8 *s) |
bool | prependString8 (unsigned char *s) |
bool | prependString8 (const unsigned char *s) |
bool | prependString16 (char16 c) |
bool | prependString16 (char16 *s) |
bool | operator+= (const char *s) |
bool | operator+= (char c) |
bool | operator+= (const char16 *s) |
bool | operator+= (char16 c) |
bool | operator= (const char *s) |
bool | operator= (const char16 *s) |
bool | operator= (char8 c) |
bool | operator= (char16 c) |
void | endString () |
void | endString8 () |
void | endString16 () |
bool | makeHexString (String &result) |
bool | fromHexString (const char8 *string) |
operator void * () const | |
conversion | |
char * | str () const |
conversion | |
char8 * | str8 () const |
conversion | |
char16 * | str16 () const |
conversion | |
int8 * | int8Ptr () const |
conversion | |
uint8 * | uint8Ptr () const |
conversion | |
int16 * | int16Ptr () const |
conversion | |
uint16 * | uint16Ptr () const |
conversion | |
int32 * | int32Ptr () const |
conversion | |
uint32 * | uint32Ptr () const |
conversion | |
float * | floatPtr () const |
conversion | |
double * | doublePtr () const |
conversion | |
char16 * | wcharPtr () const |
conversion | |
int8 * | operator+ (uint32 i) |
int32 | operator! () |
bool | swap (int16 swapSize) |
swap all bytes of this Buffer by the given swapSize | |
void | take (Buffer &from) |
takes another Buffer's memory, frees the current Buffer's memory | |
int8 * | pass () |
pass the current Buffer's memory | |
virtual bool | toWideString (int32 sourceCodePage) |
Converts a Buffer's content to UTF-16 from a given multi-byte code page, Buffer must contain char8 of given encoding. | |
virtual bool | toMultibyteString (int32 destCodePage) |
Converts a Buffer's content from UTF-16 to a given multi-byte code page, Buffer must contain UTF-16 encoded characters. | |
Static Public Member Functions | |
static bool | swap (void *buffer, uint32 bufferSize, int16 swapSize) |
utility, swap given number of bytes in given buffer by the given swapSize | |
Protected Attributes | |
int8 * | buffer |
uint32 | memSize |
uint32 | fillSize |
uint32 | delta |
Static Protected Attributes | |
static const uint32 | defaultDelta = 0x1000 |
A Buffer is an object-oriented wrapper for a piece of memory. It adds several utility functions, e.g. for managing the size of the Buffer, appending or prepending values or strings to it. Internally it uses the standard memory functions malloc(), free(), etc.
enum swapSize |
Buffer | ( | ) |
Default constructor, allocates no memory at all.
Buffer | ( | void * | b, | |
uint32 | size | |||
) |
Buffer | ( | uint32 | size, | |
uint8 | initVal | |||
) |
Buffer | ( | uint32 | size | ) |
~Buffer | ( | ) |
Destructor - deallocates the internal memory.
void operator= | ( | const Buffer & | buff | ) |
bool operator== | ( | const Buffer & | buff | ) | const |
uint32 getSize | ( | ) | const [inline] |
bool setSize | ( | uint32 | newSize | ) |
bool grow | ( | uint32 | memSize | ) |
bool setMaxSize | ( | uint32 | memSize | ) | [inline] |
see grow()
void fillup | ( | uint8 | initVal = 0 |
) |
set from fillSize to end
uint32 getFillSize | ( | ) | const [inline] |
bool setFillSize | ( | uint32 | c | ) |
sets a new fill size, does not change any memory
void flush | ( | ) | [inline] |
sets fill size to zero
bool truncateToFillSize | ( | ) |
bool isFull | ( | ) | const [inline] |
uint32 getFree | ( | ) | const [inline] |
void shiftStart | ( | int32 | amount | ) | [inline] |
moves all memory by given amount, grows the Buffer if necessary
void shiftAt | ( | uint32 | position, | |
int32 | amount | |||
) |
moves memory starting at the given position
void move | ( | int32 | amount, | |
uint8 | initVal = 0 | |||
) |
shifts memory at start without growing the buffer, so data is lost and initialized with init val
bool copy | ( | uint32 | from, | |
uint32 | to, | |||
uint32 | bytes | |||
) |
copies a number of bytes from one position to another, the size may be adapted
uint32 get | ( | void * | b, | |
uint32 | size | |||
) |
copy to buffer from fillSize, and shift fillSize
bool put | ( | uint8 | byte | ) |
append value at end, grows Buffer if necessary
bool put | ( | char16 | c | ) |
append value at end, grows Buffer if necessary
bool put | ( | char | c | ) |
append value at end, grows Buffer if necessary
bool put | ( | const void * | toPut, | |
uint32 | size | |||
) |
append bytes from a given buffer, grows Buffer if necessary
bool put | ( | void * | p, | |
uint32 | size | |||
) | [inline] |
append bytes from a given buffer, grows Buffer if necessary
bool put | ( | uint8 * | p, | |
uint32 | size | |||
) | [inline] |
append bytes from a given buffer, grows Buffer if necessary
bool put | ( | char8 * | p, | |
uint32 | size | |||
) | [inline] |
append bytes from a given buffer, grows Buffer if necessary
bool put | ( | const uint8 * | p, | |
uint32 | size | |||
) | [inline] |
append bytes from a given buffer, grows Buffer if necessary
bool put | ( | const char8 * | p, | |
uint32 | size | |||
) | [inline] |
append bytes from a given buffer, grows Buffer if necessary
void set | ( | uint8 | value | ) |
fills complete Buffer with given value
bool appendString | ( | const char * | s | ) | [inline] |
bool appendString | ( | char * | s | ) | [inline] |
bool appendString | ( | char | c | ) | [inline] |
bool appendString8 | ( | const char8 * | s | ) |
bool appendString16 | ( | const char16 * | s | ) |
bool appendString8 | ( | char8 * | s | ) | [inline] |
bool appendString8 | ( | unsigned char * | s | ) | [inline] |
bool appendString8 | ( | const unsigned char * | s | ) | [inline] |
bool appendString8 | ( | char8 | c | ) | [inline] |
bool appendString8 | ( | unsigned char | c | ) | [inline] |
bool appendString16 | ( | char16 | c | ) | [inline] |
bool appendString16 | ( | char16 * | s | ) | [inline] |
bool prependString | ( | const char * | s | ) | [inline] |
bool prependString | ( | char * | s | ) | [inline] |
bool prependString | ( | char | c | ) | [inline] |
bool prependString8 | ( | const char8 * | s | ) |
bool prependString16 | ( | const char16 * | s | ) |
bool prependString8 | ( | char8 | c | ) |
bool prependString8 | ( | unsigned char | c | ) | [inline] |
bool prependString8 | ( | char8 * | s | ) | [inline] |
bool prependString8 | ( | unsigned char * | s | ) | [inline] |
bool prependString8 | ( | const unsigned char * | s | ) | [inline] |
bool prependString16 | ( | char16 | c | ) |
bool prependString16 | ( | char16 * | s | ) | [inline] |
bool operator+= | ( | const char * | s | ) | [inline] |
bool operator+= | ( | char | c | ) | [inline] |
bool operator+= | ( | const char16 * | s | ) | [inline] |
bool operator+= | ( | char16 | c | ) | [inline] |
bool operator= | ( | const char * | s | ) | [inline] |
bool operator= | ( | const char16 * | s | ) | [inline] |
bool operator= | ( | char8 | c | ) | [inline] |
bool operator= | ( | char16 | c | ) | [inline] |
void endString | ( | ) | [inline] |
void endString8 | ( | ) | [inline] |
void endString16 | ( | ) | [inline] |
bool makeHexString | ( | String & | result | ) |
bool fromHexString | ( | const char8 * | string | ) |
operator void * | ( | ) | const [inline] |
conversion
char* str | ( | ) | const [inline] |
conversion
char8* str8 | ( | ) | const [inline] |
conversion
char16* str16 | ( | ) | const [inline] |
conversion
int8* int8Ptr | ( | ) | const [inline] |
conversion
uint8* uint8Ptr | ( | ) | const [inline] |
conversion
int16* int16Ptr | ( | ) | const [inline] |
conversion
uint16* uint16Ptr | ( | ) | const [inline] |
conversion
int32* int32Ptr | ( | ) | const [inline] |
conversion
uint32* uint32Ptr | ( | ) | const [inline] |
conversion
float* floatPtr | ( | ) | const [inline] |
conversion
double* doublePtr | ( | ) | const [inline] |
conversion
char16* wcharPtr | ( | ) | const [inline] |
conversion
int8 * operator+ | ( | uint32 | i | ) |
int32 operator! | ( | ) | [inline] |
bool swap | ( | int16 | swapSize | ) |
swap all bytes of this Buffer by the given swapSize
bool swap | ( | void * | buffer, | |
uint32 | bufferSize, | |||
int16 | swapSize | |||
) | [static] |
utility, swap given number of bytes in given buffer by the given swapSize
void take | ( | Buffer & | from | ) |
takes another Buffer's memory, frees the current Buffer's memory
int8 * pass | ( | ) |
pass the current Buffer's memory
bool toWideString | ( | int32 | sourceCodePage | ) | [virtual] |
Converts a Buffer's content to UTF-16 from a given multi-byte code page, Buffer must contain char8 of given encoding.
[in] | sourceCodePage | : the actual code page of the Buffer's content |
bool toMultibyteString | ( | int32 | destCodePage | ) | [virtual] |
Converts a Buffer's content from UTF-16 to a given multi-byte code page, Buffer must contain UTF-16 encoded characters.
[in] | destCodePage | : the desired code page to convert the Buffer's content to |
const uint32 defaultDelta = 0x1000 [static, protected] |
int8* buffer [protected] |
uint32 memSize [protected] |
uint32 fillSize [protected] |
uint32 delta [protected] |